package com.life.ai.server.framework.osssts;

import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * StsCredentials
 *
 * @author kylewka
 * @since 2023/8/8
 */
@Data
public class StsCredentials implements Serializable {
    private static final long serialVersionUID = 1L;

    private String securityToken;

    private Date expiration;

    private String accessKeySecret;

    private String accessKeyId;

    public StsCredentials() {
    }

    public StsCredentials(AssumeRoleResponse.Credentials credentials, Long cacheDuration) {
        this.securityToken = credentials.getSecurityToken();
        this.accessKeySecret = credentials.getAccessKeySecret();
        this.accessKeyId = credentials.getAccessKeyId();
        this.expiration = new Date(System.currentTimeMillis() + cacheDuration);
    }
}
